﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AcademicScheduleForm.ascx.cs" Inherits="AcademicPlanner.Presentation.Views.Shared.AcademicScheduleForm" %>
<%@ Import Namespace="AcademicPlanner.Framework.Libraries.Mvc" %>
<%@ Import Namespace="AcademicPlanner.Framework.Helpers" %>
<%@ Import Namespace="AcademicPlanner.Presentation" %>
<%@ Import Namespace="AcademicPlanner.Presentation" %>
<%@ Import Namespace="AcademicPlanner.Presentation.Views.Shared" %>
<%@ Import Namespace="AcademicPlanner.Domain.Models" %>

<% if (!Model.IsSub)
   { %>
		<div class="form yui-skin-sam">
		<% Begin(); %>
<% } %>

<% if (!string.IsNullOrEmpty(Title))
   { %>
		<fieldset><legend><%= Html.Encode(Title) %></legend>
<% } %>

<% if (!Model.IsSub)
   { %>
		<%= WidgetHelper.FormErrorsBlock("", Model.Id + "Errors", "hidden")%>
<% } %>



<% if (Model.Scenario == AcademicScheduleFormScenario.CREATE
		|| Model.Scenario == AcademicScheduleFormScenario.EDIT)
   {
	%>
		<div class="rows-wrapper">
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("Name"), Html.Encode(Tr(Labels.Get("Name", "AcademicSchedule"))), true)%>
				</div>
				<div class="cell">
					<%= Html.TextField(GetFieldName("Name"), NameValue)%>
				</div>
			</div>
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("StartYear"), Html.Encode(Tr(Labels.Get("StartYear", "AcademicSchedule"))), true)%>
				</div>
				<div class="cell">
					<%	if (Model.Scenario == AcademicScheduleFormScenario.EDIT)
						{ %>
							<i><%= Html.Encode(Model.Schedule.StartYear) %></i>
					<%	}
						else
						{ %>
							<%= Html.TextField(GetFieldName("StartYear"), StartYearValue)%>
					<%	} %>
				</div>
			</div>
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("Program"), Html.Encode(Tr(Labels.Get("Program", "AcademicSchedule"))), true)%>
				</div>
				<div class="cell">
					<%	if (Model.Scenario == AcademicScheduleFormScenario.EDIT)
						{ %>
							<i><%= Html.Encode(Model.Schedule.Program.Name) %></i>
					<%	}
						else
						{ %>
							<%	if (ProgramOptions.Count > 0)
								{ %>
								<%= Html.DropDownList(GetFieldName("Program"), ProgramOptions)%>
							<%	} 
								else 
								{ %>
									<%= Html.ActionLink(Tr("Click here"), "List", "Programs", new { pId = Model.AcademicPlan.EntityId }, new { })%>
									to create Programs first!
								<% } %>
					<%	} %>
				</div>
			</div>
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("StartTerm"), Html.Encode(Tr(Labels.Get("StartTerm", "AcademicSchedule"))), true)%>
				</div>
				<div class="cell">
					<%	if (Model.Scenario == AcademicScheduleFormScenario.EDIT)
						{ %>
							<i><%= Html.Encode(Model.Schedule.StartTerm.Name)%></i>
					<%	}
						else
						{ %>
							<%	if (StartTermOptions.Count > 0)
								{ %>
								<%= Html.DropDownList(GetFieldName("StartTerm"), StartTermOptions)%>
							<%	} 
								else 
								{ %>
									<a href="<%= Url.Action("Overview", "MyPlan") %>#planSettings=edit">
										<%= Tr("Click here") %></a>
									to add Terms first!
								<% } %>
					<%	} %>
				</div>
			</div>
		</div>
<% } %>



<% if (!Model.IsSub)
   { %>
		<div class="rows-wrapper action">
			<div class="row">
				<div class="cell label">
					&nbsp;
				</div>
				<div class="cell">
					<%= Html.SubmitButton("submitForm", Html.Encode(SubmitButtonValue), "") %>
				</div>
			</div>
		</div>
<% } %>


<% if (!string.IsNullOrEmpty(Title))
   { %>
		</fieldset>
<% } %>


<% if (!Model.IsSub)
   { %>
		<% End(); %>
		</div>
<% } %>